function json_post(url, params, success, error) {
    $.ajax({
        type: 'POST',
        url: url,
        data: params,
        dataType: "json",
        success: function(result) {
            success(result);
        },
        error: function(result) {
            error(result);
        }
    });
}

function json_get(url, params, success, error) {
    $.ajax({
        type: 'GET',
        url: url,
        data: params,
        dataType: "json",
        success: function(result) {
            success(result);
        },
        error: function(result) {
            error(result);
        }
    });
}

function login() {
    var username = $('#login-username').val();
    var password = $('#login-password').val();
    var params = {
        'username': username,
        'password': password
    };
    var url = "login";
    json_post(url, params, login_success, login_error);
}

function login_success(result) {
    if(result != null) {
        alert(result.resultCode);
    } else {
        alert("result is null");
    }
}

function login_error(result) {
    alert("login error: " + result);
}

function register() {

}

function test() {
    window.location.href = "";
}